export const TYPES = {
  GROUP: 'group',
  DEFAULT: 'DEFAULT'
}
export const createApply = (structure = []) => {
  if (!structure || !Array.isArray(structure)) return []
  const groups = []
  structure.forEach(s => {
    let group = null
    switch (s.type) {
      case TYPES.GROUP:
        group = Object.assign({}, s, {list: []})
        break
      default:
        group = s
        break
    }
    groups.push(group)
  })
  return groups
}
/**
 * 已有报名记录 合并报名条件
 * @param apply
 * @param structure
 * @returns {Array}
 */
export const mergeApply = (apply, structure = []) => {
  if (!structure || !Array.isArray(structure)) return []
  const groups = []
  structure.forEach(s => {
    let group = {}
    switch (s.type) {
      case TYPES.GROUP:
        group = s
        break
      default:
        group = Object.assign({}, s, {list: []})
        break
    }
    groups.push(group)
  })
  return groups
}
